$(function () {
    // isLogin();
});

function isLogin() {
    let result = localStorage.getItem("isLogin");
    console.log(result);
    if (result == null) {
        window.open("/html/login.html", "_self");
        return false;
        // location.href = "/html/login.html";
    }
    return true;
}

function srcLogin(data) {
    if (data.result == "noLogin") {
        window.open("/html/login.html", "_self");
        return false;
    }
    return true;

}

function myAjax(url, data, type) {
    let result = {};
    let user = {
        loginUsername: localStorage.getItem("loginUsername")
    };
    $.ajax({
        url: url,
        data: Object.assign(data, user),
        type: type,
        async: false,//异步
        dataType: 'json',//返回json对象
        success: function (data) {//返回成功以后执行里面的方法
            result = data;
        }
    });
    return result;

}

function myImgAjax(url, data) {
    // if (!isLogin())
    //     return;
    let result = {};
    let user = {
        loginUsername: localStorage.getItem("loginUsername")
    };
    $.ajax({
        url: url,
        data: Object.assign(data,user),
        type: 'post',
        async: false,//异步
        processData: false,
        contentType: false,
        dataType: 'json',//返回json对象
        success: function (data) {//返回成功以后执行里面的方法
            result = data;
        }
    });
    return result;

}

function load(url) {
    $(".right").load("/html/back" + url);
}